<!DOCTYPE>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>字典编辑</title>
    <link rel="stylesheet" href="../static/lib/layui/css/layui.css"  media="all">
    <link rel="stylesheet" type="text/css" href="../static/plugin/layer/skin/layer.css">
    <style type="text/css">
        body{padding-top:10px;}
        .fl{float:left;}
        .fr{float:right;}
        .por{position: relative;}
        #pagination{margin:0 20px;}
        .layui-form{margin:0 20px;}
        .update input{position: absolute;height:36px;width:100px;z-index:3;opacity: .01;cursor: pointer;}
        .update span{color:#5FB878;position: absolute;left:0;top:0;width: 110px;height:36px;text-align:center;line-height:36px;border:1px solid #ddd;border-bottom-right-radius: 2px;border-top-right-radius:2px;font-size:20px;}
        .update i{color:#000;font-style: normal;font-size:16px;}
        .x-red{color:red;}
        .layui-form-item{line-height: 38px;}
    </style>
</head>
<body>
<div id="createApp">
    <div >
        <form class="layui-form layui-form-pane" action="">
            <input type="hidden" name="id" v-model="parameter.id"   autocomplete="off" class="layui-input">
            <div class="layui-form-item">
                <label class="layui-form-label">内容值 </label>
                <div class="layui-input-inline" >
                    <input type="text" name="name"  v-model="parameter.name" placeholder="请输入字典名称" autocomplete="off" class="layui-input" @blur="verify(parameter.name)">
                </div>
                <span class="x-red">*必填</span>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容分数 </label>
                <div class="layui-input-inline" >
                    <input type="text" name="code"  v-model="parameter.code" placeholder="请输入字典编号" autocomplete="off" class="layui-input" @blur="verifyNum(parameter.code)">
                </div>
                <span class="x-red">*必填</span>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-inline">
                    <input type="text" name="type" v-model="parameter.type" lay-verify="required" placeholder="请输入字典类型" autocomplete="off" class="layui-input" @blur="verify(parameter.type)">
                </div>
                <span class="x-red">*必填</span>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分数</label>
                <div class="layui-input-inline">
                    <input type="text" name="description" v-model="parameter.description" lay-verify="required" placeholder="请输入字典描述" autocomplete="off" class="layui-input" @blur="verify(parameter.description)">
                </div>
                <span class="x-red">*必填</span>
            </div>

        </form>
        <div class="layui-form-item">
            <label class="layui-form-label"></label><button class="layui-btn" lay-submit="" lay-filter="demo2" @click="sub">提交</button>
        </div>
    </div>
</div>
<script src="../static/lib/jquery.min.js"></script>
<script src="../static/lib/layui/layui.js" charset="utf-8"></script>
<script src="../static/lib/vue.min.js"></script>
<script src="../static/lib/x-layui.js"></script>
<script type="text/javascript">
    var myid="${content.id}"
    if(myid==""){
        var kid=""
        //alert("1213")
    }else {
        kid="$!{content.id}"
       // alert(kid)
    }
    var VM = new Vue({
        el:"#createApp",
        data:{
            parameter:{
                name:'$!{content.value}',
                mark:'$!{content.mark}',
                type:'$!{content.type}',
                order:'$!{content.order}',
                createTime:'$!{content.createTime}',
                updateTime:'$!{content.updateTime}',
                updateUser:"$!{content.updateUser}",
                createUser:"$!{content.createUser}",
                id:kid
            }
        },
        methods:{
           /* verify:function (item) {
                if(item == ""){
                    layer.msg("必填项不能为空！", {icon: 1});
                    return false;
                }
            },
            verifyNum:function (item) {
                var _this = this;
                if(item == ""){
                    layer.msg("必填项不能为空！", {icon: 1});
                    return false;
                }else if(isNaN(item)){
                    layer.msg("字典编号必须为数字！", {icon: 1});
                    _this.parameter.code = "";
                    return false;
                }
            },*/
            sub:function () {
                var _this = this;
               /* if(this.parameter.name == "" ){
                    layer.msg("请输入字典名称！", {icon: 1});
                    return false;
                }else if(this.parameter.code == ""){
                    layer.msg("请输入字典编号！", {icon: 1});
                    return false;
                }
                else if(this.parameter.type == ""){
                    layer.msg("请输入字典类型！", {icon: 1});
                    return false;
                }
                else if(this.parameter.description == ""){
                    layer.msg("请输入字典描述！", {icon: 1});
                    return false;
                }*/
                $.ajax({
                    type: "post",
                    url: "../QsContent/saveOrUpdate.do",
                    data: _this.parameter,
                    dataType: "json",
                    success: function(data){
                        //alert("sdsd")
                        //关闭窗口
                      var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                       parent.layer.close(index);
                       parent.window.location.reload();
                        window.location.href = "javascript:location.replace(location.href)";
                    }
                });
            }
        }
    });//vue 实例结束
    layui.use(['layer',"form",'laydate'], function(){
        var form = layui.form(),
                layer = layui.layer,
                laydate = layui.laydate;
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input.checkbox');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

    });
</script>
</body>
</html>